import pandas as pd
import numpy as np

rng = pd.date_range('1/1/2012', periods=100, freq='S')
print(rng)

ts = pd.Series(np.random.randint(0, 500, len(rng)), index=rng)
print(ts)

ts_sum = ts.resample('5Min').sum()
print(ts_sum)

rng = pd.date_range('3/6/2012 00:00', periods=5, freq='D')
ts = pd.Series(np.random.randn(len(rng)), rng)
ts_utc = ts.tz_localize('UTC')
ts_utc.tz_convert('US/Eastern')

rng = pd.date_range('1/1/2012', periods=5, freq='M')
ts = pd.Series(np.random.randn(len(rng)), index=rng)
ps = ts.to_period() # to Month 2012-01
print(ps)

ps.to_timestamp()